<?php
	
	$fields = array("firstname", "lastname", "email");
	$fieldn = array("First Name:", "Last Name:", "Email:");
					
?>

<form class="form-horizontal" action="process.php" method="POST" id="edit-form" onkeypress="return event.keyCode != 13;">


<?php foreach($fieldn as $index=>$field): ?>

	<?php $error = ($form->error($fields[$index]) != ""); ?>
	<div class="row span9 personal-field-row control-group <?php if ($error) echo 'error'; ?>" data-backup='<?php echo $session->userinfo[$fields[$index]]; ?>' id='<?php echo $fields[$index]; ?>'>
		<div class="span2 field" <?php if ($error) echo "style='color:red;'";?>><?php echo $field; ?></div>	
		<?php if (!$error) { ?>
			<div class="span2 personalData"><?php echo $session->userinfo[$fields[$index]]; ?></div> 
			<div class="span1"><i class="icon-pencil edit"></i></div>
		<?php } else { ?>
			<div class='span2 editData'><input type='text' class='input-small' name='<?php echo $field; ?>'></input></div> 
			<div class="span1"><i class="icon-remove edit"></i></div>
		<?php  } ?>
		<?php if ($error) { ?>
			<span class="span2" style="color: red"><?php echo $form->error($fields[$index]);?></span>
		<?php } ?>
	</div>	
	
	<div class="row span5 seperator" ></div>
	
<?php endforeach; ?>

	<div class="row span6 personal-field-row" data-backup='<?php echo  $session->userinfo["gender"] == 1 ? "Male" : "Female"; ?>' id='gender'>	
		<div class="span2 field">Gender:</div>
		<div class="span2 personalData"><?php echo $session->userinfo["gender"] == 1 ? "Male" : "Female"; ?></div>
		<div class="span1"><i class="icon-pencil edit"></i></div>
		<div class="form-actions hidden" style="margin-top: 70px;">
			<button type="button" class="btn btn-primary" id="profile-edit-submit">Save Changes</button>
			<button type="button" class="btn profile-edit-cancel">Cancel</button>
		</div>	
	</div>
	<input type="hidden" name="subedit" value="1">
	<input type="hidden" name="pass" id="pass"></input>
	<input type="hidden" name="oldEmail" id="oldEmail"></input>
	
</form>	
